//This header contain planning algorythms for process/threads
//ANSI C
#define C 12345
#define A 1103515245
#define M 42949672
#include "math.h"
#include "th.h"
//simple rnd, for lottery
static int x=0;
int rand()
{
    x=(A*x+C)%M;
    if(x>0)
    return x*2/1000000;
    return -1*x*2/1000000;
}

static bil_t used_bills=0;

ith_t lottery()
{
    int res=rand(),i;
    for(i=0;i<th_count;i++)
    {
        if(th_table.bil<res)
        continue;

        return th_table.id;
    }
}

int set_bills(ith_t id, bil_t bills)
{
    int n=find_th(id);
    th_table[n].bills=bills;
    return SUCCESS;
}

